<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html style="overflow-y: visible;">
    <jsp:include page="../../../include/IncludeMain.jsp"></jsp:include>
  <body style="overflow-y: visible!important;overflow-y: scroll;">
	  <form action="${pageContext.request.contextPath }/pages/purchase/purchaseDetailAction!save?purchase_id=${purchase_id }" name="myForm" id="myForm" method="post">
		<input type="hidden" name="purchase_id" value="${purchase_id}"/>
	    	<table class="mainTable">
				<thead>
					<tr class="tableController">
						<th colspan="2">
							<h3>采购明细编辑</h3>
						</th>
					</tr>
					<tr>
						<th>&nbsp;	</th>
						<th class="errorTip" style='<c:if test="${empty message}">display:none</c:if>'>
							<c:forEach items="${message}" var="m">
								${m }
							</c:forEach>
						</th>
					</tr>
					<tr class="tableTitle">
						<th>
							<h3>&nbsp;</h3>
						</th>
						<th>
							<h3>&nbsp;</h3>
						</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td width="200" align="right"><h4>材料料号:&nbsp;&nbsp;</h4></td>
						<td>						
							<input type="hidden" name="purchaseDetail.id" id="id" value="${purchaseDetailView.id}"/> 
							<input type="hidden" name="purchaseDetail.status" id="status" value="${purchaseDetailView.status}"/> 
							<select validation="required=1"  name="MaterialDatas" id="materialId" style="width:126" onchange="change(this.value)">
								<option value="">请选择</option>
								<c:forEach items="${materialList}" var="MaterialData">
									<option value="${MaterialData.id },${MaterialData.name },${MaterialData.unit }" <c:if test="${purchaseDetailView.material_iid == MaterialData.id}">selected</c:if>>${MaterialData.material_id }</option>
								</c:forEach>
							</select>
							<em style="color:red;">*</em>
						</td>
					</tr> 
					<tr>
						<td align="right"><h4>材料名称:&nbsp;&nbsp;</h4></td>
						<td id="material_name">
							&nbsp;${purchaseDetailView.material_name }
						</td>
					</tr>
					<tr>
						<td width="200" align="right"><h4>供应商名称:&nbsp;&nbsp;</h4></td>
						<td>
							<select validation="required=1"  name="supplier_id" id="supplierId" style="width:126" >
									<option value="">请选择</option>
								<c:forEach items="${supplierList}" var="SupplierData">
									<option value="${SupplierData.id }" <c:if test="${purchaseDetailView.supplier_iid == SupplierData.id}">selected</c:if>>${SupplierData.name }</option>
								</c:forEach>
							</select>
							<em style="color:red;">*</em>
						</td>
					</tr>
					<tr>
						<td align="right"><h4>数量:&nbsp;&nbsp;</h4></td>
						<td>
							<input type="text" validation="required,number" name="purchaseDetail.amount" id="amount" value="${purchaseDetailView.amount}"/>
							<em style="color:red;">*</em>
						</td>
					</tr> 
					<tr>
						<td align="right"><h4>单位:&nbsp;&nbsp;</h4></td>
						<td id="unit">
							&nbsp;${purchaseDetailView.unit }
						</td>
					</tr> 
					<tr>
						<td align="right"><h4>备注:&nbsp;&nbsp;</h4></td>
						<td><textarea cols="40" rows="5" name="purchaseDetail.comments" id="comments">${purchaseDetailView.comments}</textarea></td>
					</tr> 
				</tbody>
				<tfoot>
					<tr  class="tableController_bottom">
						<td align="center">
							&nbsp;
						</td>
						<td align="left">
							<a class="button" href="javascript:void(0)" onclick="this.blur(); save();'return false';"><span><img src="${pageContext.request.contextPath }/js/kui/icons/disk.png" align="absmiddle"/>&nbsp;保存</span></a>
							<a class="button" href="javascript:void(0)" onclick="this.blur(); history.go(-1);'return false';"><span><img src="${pageContext.request.contextPath }/js/kui/icons/anticlockwise.png" align="absmiddle"/>&nbsp;返回</span></a>
						</td>
					</tr>
				</tfoot>
		</table>
		</form>
		<script type="text/javascript">
		
			var formId = 'myForm';
			var valid = new KUI.Validation({formId: formId, immediate: true});
			function save(){
				if(valid.validate()){
					document.getElementById(formId).submit();
				}
			}
			function change(s){
				var strs = new String(s)
				var str = strs.split(",")
				
				document.getElementById("material_name").innerHTML=str[1];
				document.getElementById("unit").innerHTML=str[2];
			}
		</script>
  </body>
</html>
